//
//  GoodsCell.m
//  MyTest
//
//  Created by zhiyou on 16-4-18.
//  Copyright (c) 2016年 wangyang. All rights reserved.
//

#import "GoodsCell.h"

@implementation GoodsCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _headView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:_headView];
        
        _tagLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _tagLab.font = [UIFont systemFontOfSize:11];
        _tagLab.textColor = [UIColor redColor];
        [self.contentView addSubview:_tagLab];
        
        _nameLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _nameLab.font = [UIFont systemFontOfSize:11];
        _nameLab.numberOfLines = 0;
        [self.contentView addSubview:_nameLab];
        
        _contentLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _contentLab.font = [UIFont systemFontOfSize:11];
        _contentLab.numberOfLines = 0;
        [self.contentView addSubview:_contentLab];
        
        _storeLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _storeLab.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_storeLab];
        
        _priceLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _priceLab.font = [UIFont systemFontOfSize:11];
        _priceLab.textColor = [UIColor redColor];
        [self.contentView addSubview:_priceLab];
        
        _timeLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _timeLab.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_timeLab];

        
        [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.offset(5);
            make.bottom.offset(-5);
            make.width.equalTo(_headView.mas_height);
        }];
        
        [_tagLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset(5);
            make.top.offset(10);
        }];
        
        [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_tagLab.mas_right).offset(5);
            make.width.equalTo(self.mas_width).multipliedBy(.5);
            make.top.offset(10);
        }];
        
        [_contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset(5);
            make.top.equalTo(_nameLab.mas_bottom).offset(20);
            make.right.offset(-5);
        }];
        
        [_storeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset(5);
            make.bottom.offset(-5);
        }];
        
        [_priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_storeLab.mas_right).offset(5);
            make.bottom.offset(-5);
        }];
        
        [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.bottom.offset(-5);
        }];
    }
    return self;
}


- (void)setDongTai:(DongTai *)dongTai
{
    _dongTai = dongTai;
    
    [_headView sd_setImageWithURL:[NSURL URLWithString:_dongTai.pic]];
    _tagLab.text = dongTai.tag;
    _nameLab.text = dongTai.goodsName;
    _contentLab.text = dongTai.content;
    _storeLab.text = dongTai.store;
    _priceLab.text = dongTai.price;
    _timeLab.text = dongTai.date;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
